﻿package KK.Queue {
	
	public class QObject implements IQueueObject{
		static public const COMPLETE:int=0;
		static public const START:int=1;
		static public const WAIT:int=2;
		static public const CANCEL:int=3;
		
		private var _queue:IQueue;
		
		protected var status:int;//0是完成，1是开始，2是等待,3是取消
		public function QObject() {
			// constructor code
			init();
		}
		private function init():void{
			status=0;
		}
		public function Run(_queue:IQueue):void{
			this._queue=_queue;
			status=START;
			Start();
		}
		public function Start():void{
		}
		protected function Complete():void{
			
			if(null!=_queue)
			{
				_queue.Complete(this);
			}
			Reset();
		}
		public function Cancel():int{
			status=CANCEL;
			return 0;
		}
		public function get Status():int{
			//0是完成，1是开始，2是等待,3是取消
			return this.status;
		}
		public function Reset():int{
			this.status=COMPLETE;
			this._queue=null;
			return 0;
		}
	}
	
}
